<!-- 
*   @Description:患病信息
*   @Author:lxy
*   @Date:2023-03-23 10:23
-->
<template>
  <div>
    <div class="historyOfIllness publicClass">
      <!-- //既往患病史 -->
      <div class="historyOfIllness_box">
        <div class="bel_title">既往患病史</div>
        <el-checkbox-group v-model="bigObject.checkList" class="checkoutArray">
          <el-checkbox :label="item.label" class="checkoutItem" v-for="(item,index) in topData" :key="index">{{ item.text }}</el-checkbox>
        </el-checkbox-group>
        <div class="qita">
          <span>其他备注：</span>
          <el-input type="textarea" resize="none" :rows="2" placeholder="请输入内容" v-model="bigObject.jiwangInputValue" class="jiwangInputValue"></el-input>
        </div>
      </div>
    </div>
    <div class="allergyHistory publicClass">
      <!-- //过敏史 -->
      <div class="allergyHistory_box">
        <div class="bel_title">过敏史</div>
        <div class="allergyHis_list">
          <span class="hisTile">吸入性过敏：</span>
          <el-checkbox-group v-model="bigObject.xiruCheckoutArray" class="hisCheckout">
            <el-checkbox label="花粉">花粉</el-checkbox>
            <el-checkbox label="棉絮">棉絮</el-checkbox>
            <el-checkbox label="油烟">油烟</el-checkbox>
          </el-checkbox-group>
          <div class="BEIdiv">
            <input type="text" class="BELInput" placeholder="其他" v-model="bigObject.xiRuInputValue">
          </div>
        </div>

        <div class="allergyHis_list">
          <span class="hisTile">食入性过敏：</span>
          <el-checkbox-group v-model="bigObject.shiRuCheckoutArray" class="hisCheckout">
              <el-checkbox label="海鲜">海鲜</el-checkbox>
              <el-checkbox label="蔬果">蔬果</el-checkbox>
              <el-checkbox label="牛奶">牛奶</el-checkbox>
            </el-checkbox-group>
          <div class="BEIdiv">
            <input type="text" class="BELInput"  placeholder="其他" v-model="bigObject.ShiRuInputValue">
          </div>
        </div>

        <div class="allergyHis_list">
          <span class="hisTile">接触性过敏：</span>
            <el-checkbox-group v-model="bigObject.jieChuCheckoutArray" class="hisCheckout">
              <el-checkbox label="冷空气">冷空气</el-checkbox>
              <el-checkbox label="紫外线">紫外线</el-checkbox>
              <el-checkbox label="细菌">细菌</el-checkbox>
            </el-checkbox-group>
          <div class="BEIdiv">
            <input type="text" class="BELInput"  placeholder="其他" v-model="bigObject.jieChuInputValue">
          </div>
        </div>

        <div class="allergyHis_list">
          <span class="hisTile">注射性过敏：</span>
            <el-checkbox-group v-model="bigObject.zhuSheCheckoutArray" class="hisCheckout">
              <el-checkbox label="链霉素">链霉素</el-checkbox>
              <el-checkbox label="青霉素">青霉素</el-checkbox>
              <el-checkbox label="异种血清">异种血清</el-checkbox>
            </el-checkbox-group>
          <div class="BEIdiv">
            <input type="text" class="BELInput" placeholder="其他" v-model="bigObject.zhuSheInputValue">
          </div>
        </div>

        <div class="allergyHis_list">
          <span class="hisTile">其他：</span>
          <div class="BEIdiv">
            <input type="text" class="BELInput" placeholder="其他" v-model="bigObject.qitaInputValue">
          </div>
        </div>

      </div>
    </div>
  </div>
</template>

<script>
import {previousMedicalHistory} from './beIllMessage'
import _ from 'lodash'
export default {
  name: "beIllMessage",
  data() {
    return {
      topData:[
        {label:'hypertension',text:'高血压'},
        {label:'diabetes',text:'糖尿病'},
        {label:'intestinalTractDisease',text:'肠胃道疾病'},
        {label:'hyperlipidemia',text:'高血脂'},
        {label:'tuberculosis',text:'结核病'},
        {label:'coagulation',text:'凝血管意外'},
        {label:'coronaryHeartDisease',text:'冠心病'},
        {label:'tumor',text:'肿瘤'},
        {label:'connectiveTissueDisease',text:'结缔组织病'},
        {label:'lungDisease',text:'肺部疾病'},
        {label:'chemotherapy',text:'用过化疗药物'},
      ],
      bigObject:{
        jiwangInputValue:'',         //既往患病史输入
        xiRuInputValue:'',           //吸入性过敏 其他输入
        ShiRuInputValue:'',           //食入性过敏 其他输入
        jieChuInputValue:'',        //接触性过敏 其他输入
        zhuSheInputValue:'',        //注射性过敏  其他输入
        qitaInputValue:'',          //其他输入
        checkList: [],    //既往患病史
        xiruCheckoutArray:[],    //吸入性过敏
        shiRuCheckoutArray:[],   //食入性过敏
        jieChuCheckoutArray:[],   //接触性过敏
        zhuSheCheckoutArray:[],  //注射性过敏
      },
    };
  },
  methods:{
    modifyFunction(){
      let huanbingshi = this.modifyFunctionOne()
      let guominshi = this.modifyFunctionTwo()
      return {huanbingshi,guominshi}
    },
    modifyFunctionOne(){
      let toplHistory = _.cloneDeep(previousMedicalHistory)
      this.bigObject.checkList.forEach(item => {
        for(let i in toplHistory){
          if(i == item) toplHistory[i] = 1
        }
        toplHistory.notes = this.bigObject.jiwangInputValue == '' ? '无' : this.bigObject.jiwangInputValue

      });

      return toplHistory
    },
    modifyFunctionTwo(){
      let strObject = {
        xiStr:'',         //吸入性过敏
        shiStr:'',        //食入性过敏
        jieChuStr:'',      //接触性过敏
        zhuSheStr:'',      //注射性过敏
        qiTaStr:''        //其他
      }
      if(!this.bigObject.xiruCheckoutArray.length && this.bigObject.xiRuInputValue=='') strObject.xiStr = '无'
      else this.bigObject.xiruCheckoutArray.forEach(item=>strObject.xiStr += (item+'、'))
      strObject.xiStr = this.screenFunction(strObject.xiStr,this.bigObject.xiRuInputValue)

      if(!this.bigObject.shiRuCheckoutArray.length && this.bigObject.ShiRuInputValue=='') strObject.shiStr = '无'
      else this.bigObject.shiRuCheckoutArray.forEach(item=>strObject.shiStr += (item+'、'))
      strObject.shiStr = this.screenFunction(strObject.shiStr,this.bigObject.ShiRuInputValue)

      if(!this.bigObject.jieChuCheckoutArray.length && this.bigObject.jieChuInputValue=='') strObject.jieChuStr = '无'
      else this.bigObject.jieChuCheckoutArray.forEach(item=>strObject.jieChuStr += (item+'、'))
      strObject.jieChuStr = this.screenFunction(strObject.jieChuStr,this.bigObject.jieChuInputValue)

      if(!this.bigObject.zhuSheCheckoutArray.length && this.bigObject.zhuSheInputValue=='') strObject.zhuSheStr = '无'
      else this.bigObject.zhuSheCheckoutArray.forEach(item=>strObject.zhuSheStr += (item+'、'))
      strObject.zhuSheStr = this.screenFunction(strObject.zhuSheStr,this.bigObject.zhuSheInputValue)

      strObject.qiTaStr = this.bigObject.qitaInputValue == '' ? '无' : this.bigObject.qitaInputValue
      return strObject
    },
    screenFunction(data,str=''){
      //1.将两个字符串拼接上
      let dataStr = data + str
      //2.判断传过来的值最后一个字符是不是 、,是则去掉不是则返回原数据
       if(dataStr.substr(-1) != '、') return dataStr
       let retData = dataStr.slice(0,-1)
       return retData
    }
  },
};
</script>

<style scoped lang="less">
/deep/.el-checkbox__label{
  font-size: 14px;
}
.publicClass {
  width: 100%;
}
.historyOfIllness {
  box-sizing: border-box;
  margin-bottom: 50px;
  .historyOfIllness_box{
    border: 1px solid rgba(75, 70, 70, 0.555);
    margin: 20px 20px;
    padding: 30px 50px;
    position: relative;
    .checkoutArray {
      // background-color: aqua;
      display: flex;
      justify-content: space-between;
      flex-wrap: wrap;
      .checkoutItem {
        width: 190px;
        // background-color: yellow;
        margin: 15px 0px;
        display: flex;
        justify-content: left;
        align-items: center;
        /deep/.el-checkbox__label{
          width: 170px;
          color: rgba(19, 18, 18, 0.74);
          // background-color: yellow;
          white-space: nowrap;
          overflow: hidden;
          text-overflow: ellipsis;
        }
      }
    }
    .qita{
      margin: 10px 0px 5px 0px;
      display: flex;
      justify-content: space-between;
      span{
        display: inline-block;
        white-space: nowrap;
        margin-right: 5px;
      }
    }

  }
}
.allergyHistory {
  box-sizing: border-box;
  margin-bottom: 40px;
  .allergyHistory_box{
    border: 1px solid rgba(75, 70, 70, 0.555);
    margin: 20px 20px;
    padding: 30px 50px;
    position: relative;
    .allergyHis_list{
      width: 100%;
      height: 30px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      flex-wrap: nowrap;
      margin: 20px 0px;
      // background-color: red;
      .hisTile{
        display: inline-block;
        min-width: 100px;
        text-align: right;
        font-weight: bold;
        font-size: 15px;
        white-space: nowrap;
      }
      .hisCheckout{
        white-space: nowrap;
      }
      .BEIdiv{
        height: 100%;
        margin-left: 30px;
        display: flex;
        align-items: center;
        width: 100%;
        .BEIClass{
          display: inline-block;
          font-size: 14px !important;
          font-weight: 500 !important;
          outline-style: none;
        }
        .BELInput{
          width: calc(100% - 100px);
          height: 80%;
          padding: 10px 0 5px 15px;
          color: #424141;
          background: #e5e2e246;
          outline: none;
          box-shadow: none;
          border: none;
          border-radius: 5px;
          font-size: 14px;
          transition: 0.5s;
        }

      }
    }

  }
}
.bel_title{
  background-color: rgb(255, 255, 255);
  position: absolute;
  top: -14px;
  left: 40px;
  font-size: 21px;
  padding: 0px 15px;
}
</style>
